<template>
  <div class="heritageRoad">
    <!-- header -->
    <Head />
    <Banner />
    <Nav />
    <!-- /header -->

    <div class="main">
      <div class="middle">
        <div>
          <!-- 导航栏 -->
          <div class="sidebar">
            <!-- 标题 -->
            <div class="title">
              <h3>名医工作站</h3>
            </div>
            <!-- 内容 -->
            <div class="sidebarcon">
              <a v-for="item in mzygzz" @click="goDetail(item.id)">{{
                item.title
              }}</a>
              <!-- 分页 -->
              <el-pagination
                :page-size="listQuery.limit"
                @size-change="sizeChange"
                @current-change="currentChange"
                :page-count="3"
                layout="total, prev, pager, next"
                :total="listQuery.total"
                v-show="listQuery.total > 10"
              ></el-pagination>
            </div>
          </div>
          <Ewm style="width: 150px"></Ewm>
        </div>

        <!-- 导航栏 -->
        <!-- 通知公告 -->
        <div class="block">
          <!-- 标题 -->
          <div class="title">
            <h3>名医工作站</h3>
          </div>
          <!-- 内容 -->
          <div class="content">
            <div class="articl">
              <!-- 左侧照片 -->
              <div class="pic">
                <img :src="mzygzzDetail.zpurl" alt />
              </div>

              <!-- 右侧简介 -->
              <div class="disc">
                <h4>{{ mzygzzDetail.title }}</h4>
                <p>{{ mzygzzDetail.jzzjs }}</p>
                <!-- <p>
                  这个方法可以直接得到一个含有两个数组中所有value属性值不同的项的数组
                  两种不同的地方在于，第一种方式属于原生js，更加易于理解，第二种方式直接使用封装好的方法，更简便美观
                  有一种情况， 当对象数组中的元素对象含有多级时，使用后一种方法更加的简单
                </p>-->
              </div>
            </div>
            <el-tabs
              v-model="activeName"
              type="card"
              @tab-click="handleClick"
              class="tabNam"
            >
              <el-tab-pane label="简介" name="first">
                <p class="dl">{{ mzygzzDetail.gzzjj }}</p>
              </el-tab-pane>
              <el-tab-pane label="成员" name="second">
                <p class="dl">{{ mzygzzDetail.cyjs }}</p>
              </el-tab-pane>
              <el-tab-pane label="成果展示" name="third">
                <p class="dl">{{ mzygzzDetail.cgzs }}</p>
              </el-tab-pane>
              <el-tab-pane label="图片展示" name="fourth">
                <img :src="mzygzzDetail.tpzs" alt />
              </el-tab-pane>
            </el-tabs>
          </div>
        </div>
      </div>
    </div>
    <!-- footer -->
    <Footer></Footer>
    <!-- /footer -->
  </div>
</template>

<script>
import Head from "@/components/Head.vue";
import Banner from "@/components/Banner.vue";
import Nav from "@/components/Nav.vue";
import Footer from "@/components/Footer.vue";
import Ewm from "@/components/ewm.vue";
export default {
  name: "HeritageRoad",
  components: {
    Head,
    Banner,
    Nav,
    Footer,
    Ewm,
  },
  data() {
    return {
      mzygzz: [], //通知公告
      // 页码
      listQuery: {
        total: 1,
        page: 1, //页码
        limit: 10, //每页条数
      },
      mzygzzDetail: {},
      id: 1,
      // 选项卡
      activeName: "first",
    };
  },
  created() {
    this.getZxdt();
  },
  methods: {
    //首页接口
    getZxdt() {
      var query = {
        // id: "",
        page: this.listQuery.page,
        limit: this.listQuery.limit,
      };
      this.$axios
        .get("TCM/mzygzz", { params: query })
        .then((res) => {
          if (res.status == 200) {
            this.listQuery.total = res.data.count;
            this.mzygzz = res.data.data;
            console.log(this.mzygzz);
            if (this.mzygzz) {
              this.mzygzzDetail = this.mzygzz.filter(
                (item) => item.id == this.id
              )[0];
            } else {
              this.mzygzzDetail = {};
            }
          }
        })
        .catch((err) => {
          console.log(err);
        });
    },
    sizeChange(limit) {
      this.listQuery.limit = limit;
      this.currentChange(1);
    },
    currentChange(page) {
      this.listQuery.page = page;
      this.id = (page - 1) * 10 + 1;
      this.getZxdt();
    },
    goDetail(id) {
      this.id = id;
      this.getZxdt();
    },
    handleClick(tab, event) {
      console.log(tab, event);
    },
  },
};
</script>

<style lang="less" scoped>
@media screen and (max-width: 1200px) {
  .heritageRoad .main {
    margin: 0 !important;
  }
}
.heritageRoad {
  background: url("../assets/image/diwen.jpg") repeat-y;
  // 通知公告
  .main {
    margin: 0 auto;
    margin: 0 25% 0;
    height: 100%;
    background-color: #ffffff;
    overflow: hidden;
    .middle {
      height: 100%;
      padding: 0 10px 10px;
      background-color: #ffffff;
      box-sizing: border-box;
      margin-top: 20px;
      display: flex;
      justify-content: space-between;
      .sidebar {
        width: 150px;
        border: 0.5px solid #ebe4d9;
        border-top: none;
        // height: 300px;
        overflow: hidden;
        // margin-top: 20px;
        // margin-bottom: 20px;
        .sidebarcon {
          padding: 0px 10px;
          box-sizing: border-box;
          overflow-y: hidden;
          a {
            cursor: pointer;
            display: block;
            width: 100%;
            height: 36px;
            line-height: 36px;
            font-size: 14px;
            font-weight: 500;
            color: #2c3e50;
            border-bottom: 1px dotted #eaeaea;
          }
          a:before {
            display: inline-block;
            content: "●"; //'\25CF'
            padding-right: 10px;
            color: #7b4224;
            font-size: 6px;
            line-height: 36px;
          }
          a:last-child {
            border-bottom: none;
          }
          a:hover {
            color: red;
          }
        }
      }
      .block {
        flex: 1;
        margin-left: 20px;
        background-color: #ffffff;
        border: 0.5px solid #ebe4d9;
        border-top: none;
        .content {
          padding: 20px 10px 0;
          margin-bottom: 40px;
          .articl {
            display: flex;
            .pic {
              // height: 300px;
              width: 35%;
              max-width: 200px;
              margin-right: 30px;
              overflow: hidden;
              img {
                vertical-align: middle;
                width: 100%;
              }
            }
            .disc {
              flex: 1;
              height: 200px;
              padding-top: 10px;
              p {
                font-size: 14px;
                font-weight: 500;
                letter-spacing: 1px;
                line-height: 30px;
                margin: 0;
                // 超出两行显示省略号
                overflow: hidden;
                text-overflow: ellipsis;
                display: -webkit-box;
                -webkit-line-clamp: 5;
                -webkit-box-orient: vertical;
                b {
                  font-size: 16px;
                  cursor: pointer;
                }
              }
            }
          }
          .tabNam {
            img {
              width: 150px;
              float: left;
            }
          }
        }
      }
    }
  }
  .el-pagination {
    margin-top: 10px;
    padding: 0;
    text-align: center;
  }
  .el-tabs {
    margin-top: 20px;
  }
  .dl {
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 1px;
    line-height: 30px;
    margin: 0;
    // 超出两行显示省略号
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 7;
    -webkit-box-orient: vertical;
  }
  // .el-tabs__item .is-top .is-active {
  //   color: #7e4526;
  // }
}
</style>
